package net.yambal.air.LeafletMap.OverLays
{
    import net.yambal.air.LeafletMap.ILeafletOverlay;
    import net.yambal.air.LeafletMap.LatLng;
    import net.yambal.air.LeafletMap.LeafletCoreSinglton;
    import net.yambal.air.LeafletMap.Utility.ColorUtility;
    
    public class Polyline implements ILeafletOverlay{
        
        private var _LeafObject:Object;
        
        public function Polyline(latlngs:Array, color:uint = 0x0033FF, weight:int = 5, opacity:Number = 0.5, stroke:Boolean = true){
            var a:Array = new Array();
            for each (var latlan:LatLng in latlngs){
                a.push(latlan.LeafObject);
            }
            this._LeafObject = LeafletCoreSinglton.instance.polyline(a, {
                    stroke : stroke,
                    color : ColorUtility.uint2hex(color),
                    weight : weight,
                    opacity : opacity
                }
            );

        }
        
        public function bindPopup(s:String):ILeafletOverlay{
            this._LeafObject.bindPopup(s);
            return this;
        }
        
        public function openPopup():ILeafletOverlay{
            this._LeafObject.openPopup();
            return this;
        }
        
        public function get LeafObject():Object{
            return this._LeafObject;
        }
    }
}